package xyz.hzxiao;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import xyz.hzxiao.consumer.SayHelloConsumer;

/**
 * 消费者启动类
 *
 * @author ：FuXx
 * @className : xyz.hzxiao.ConsumerApplication
 * @since ：2023-05-12
 */
@EnableDubbo
@SpringBootApplication
public class ConsumerApplication {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(ConsumerApplication.class, args);
        SayHelloConsumer sayHelloConsumer = context.getBean(SayHelloConsumer.class);
//        String hello = sayHelloConsumer.sayHello("张三");
//        System.out.println(hello);

//        UserModel userModel = sayHelloConsumer.findUser("李四");
//        System.out.println(userModel);

//        UserEntity user = sayHelloConsumer.findUserById(4L);
//        System.out.println(user);
        // spring 事务测试可用。
        UserEntity userEntity = new UserEntity();
        userEntity.setName("lisi");
        userEntity.setAge(23);
        userEntity.setEmail("test6@baomidou.com");
        boolean isSuccess = sayHelloConsumer.saveNewUser(userEntity);
        System.out.println("新增用户：" + (isSuccess ? "成功" : "失败"));

    }
}
